package sapling.utils;

/**
 * Created by mac on 16/11/21.
 */
public class Msg<T> {
    private boolean state;
    private String msg;
    private T res;
    public Msg(boolean state, String msg, T res){
        this.state=state;
        if(state){
            this.msg="success";
        }else {
            this.msg=msg;
        }
        this.res=res;
    }
    public Msg(boolean state){
        this.state=state;
        if(state){
            this.msg="success";
        }
    }
    public static Msg newMsg(Object t){
        Msg msg=new Msg(true,"",t);
        return msg;
    }
    public static Msg fail(String failmsg){
        Msg msg=new Msg(false,failmsg,"");
        return msg;
    }
    public boolean isState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getRes() {
        return res;
    }

    public void setRes(T res) {
        this.res = res;
    }
}
